<!--
- Author:  LiShibin.
- Date:    2017/9/22 0022.
- File:    批量完成任务
-->
<template>
  <div class="Web_Box">
    <div class="Editorstatus">
        <div class="status f-cb" v-for="plant in plantList">
          <div class="names">{{plant.flower_name || plant.m_name}}</div>
          <div class="fl Flower"><img :src="(plant.flower_image || plant.m_goods_image) ? $config.imgsite + $config.uploadImgSrc + (plant.flower_image || plant.m_goods_image) + '_w150' : defaultPlantImg"></div>
          <div class="fl status_box">
            <ul class="f-cb statu_block fl">
              <li :class="{'cur': plant.growth_status == $dictionary.growthStatus.seed}" @click="switchStatus(plant, $dictionary.growthStatus.seed)"><i class="iconfont icon-tab_potato_heighlight"></i>
                <p>种子期</p>
              </li>
              <li :class="{'cur': plant.growth_status == $dictionary.growthStatus.sprout}" @click="switchStatus(plant, $dictionary.growthStatus.sprout)"><i class="iconfont icon-zhongzi"></i>
                <p>发芽期</p>
              </li>
              <li :class="{'cur': plant.growth_status == $dictionary.growthStatus.seedling}" @click="switchStatus(plant, $dictionary.growthStatus.seedling)"><i class="iconfont icon-shuye1"></i>
                <p>幼苗期</p>
              </li>
              <li :class="{'cur': plant.growth_status == $dictionary.growthStatus.growthed}" @click="switchStatus(plant, $dictionary.growthStatus.growthed)"><i class="iconfont icon-shu1"></i>
                <p>成株期</p>
              </li>
            </ul>
          </div>
        </div>
    </div>
    <div class="buttonfinish2" @click="dealBatchTask">
      <a class="b_btn1">确定</a>
    </div>
  </div>
</template>

<script>
  import {mapModules, mapRules} from 'vuet'

  export default{
    mixins: [
      mapModules({taskIdListTmp: 'taskIdListTmp'}),
      mapRules({life: 'taskIdListTmp'})
    ],
    data() {
      return {
        defaultPlantImg: require('../../../assets/images/demo/xinqing2.png'),
        plantList: []
      }
    },
    components: {},
    created() {
      this.getPlantList()
    },
    methods: {
      switchStatus(plant, status) {
        plant.growth_status = status
      },
      getPlantList() {
        this.$request.getPlantListByTask(this.taskIdListTmp).then(data => {
          this.plantList = data
        })
      },
      dealBatchTask() {
        let statusObjList = []
        for (let i = 0; i < this.plantList.length; i++) {
          statusObjList.push({'o_id': this.plantList[i].o_id, 'growth_status': this.plantList[i].growth_status})
        }
        this.$request.dealBatchTask(statusObjList, this.taskIdListTmp).then(data => {
          this.$toast('批量完成任务成功')
          this.$router.go(-1)
        })
      }
    }
  }
</script>

<style>

</style>